﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using ThaireInvestmentWeb.Util;
using ThaireInvestmentWeb.WcfSerivce;

namespace ThaireInvestmentWeb.Models
{
    public class LoanInterestRateModel
    {
        public LoanInterestRateModel()
        {
            ScreenData = new LoanInterestRateScreenData();
            ScreenData.Header = new WcfSerivce.LoansHeader();

            Interest = new List<LoansInterestDetail>();
        }

        public LoanInterestRateModel(LoanInterestRateScreenData srcData)
        {
            ScreenData = srcData;
            if (srcData.Interests != null)
                Interest = new List<LoansInterestDetail>(srcData.Interests);
            else
                Interest = new List<LoansInterestDetail>();

        }

        public LoanInterestRateScreenData ScreenData;
        public LoansHeader LoansHeader { get { return ScreenData.Header; } }
        public string CompanyName { get { return ScreenData.Header.CompanyName; } }
        public string MaturityStatus { get { return ScreenData.Header.MaturityStatus; } }
        public string ContractNumber { get { return ScreenData.Header.ContractNumber; } }
        public string ContractStartDate { get { return WebUtil.FormatDate(ScreenData.Header.ContractStartDate); } }
        public string ContractEndDate { get { return WebUtil.FormatDate(ScreenData.Header.ContractEndDate); } }
        public string BorrowerName { get { return ScreenData.Header.BorrowerName; } }
        public string ContractAmt { get { return WebUtil.FormatDecimal2Digit(ScreenData.Header.ContractAmount); } }
        public decimal Period { set; get; }

        [Required(ErrorMessage = "โปรดระบุ")]
        [Range(0, (double)decimal.MaxValue, ErrorMessage = "ข้อมูลต้อง >= 0")]
        public decimal? Installment { set; get; }

        public List<LoansInterestDetail> Interest { get; set; }

        [Required(ErrorMessage = "โปรดระบุ")]
        [Range(0, (double)decimal.MaxValue, ErrorMessage = "ข้อมูลต้อง >= 0")]
        public decimal? NewMLR { set; get; }
        [Required(ErrorMessage = "โปรดระบุ")]
        [Range(0, (double)decimal.MaxValue, ErrorMessage = "ข้อมูลต้อง >= 0")]
        public decimal? NewMLRMinus { set; get; }
        [Required(ErrorMessage = "โปรดระบุ")]
        [Range(0, (double)decimal.MaxValue, ErrorMessage = "ข้อมูลต้อง >= 0")]
        public decimal? NewInterestRate { set; get; }
        [Required(ErrorMessage = "โปรดระบุ")]
        public DateTime? NewMLRRateDate { set; get; }
        public string NewUpdateInfo { set; get; }
        public int TotalMonth { get; set; }

        public int HeaderID { set; get; }     

        public string SubmitBtn { set; get; }  
        public bool UpdateMode { get; set; }
    }
}